package ipaddress.route;

import ipaddress.utils.WebRequestUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;

import javax.servlet.http.HttpServletRequest;

@RestController
public class GetIpAddressResource {
    @RequestMapping(value = "/ipaddress", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    public String getIpAddress(HttpServletRequest request){
        return WebRequestUtils.getRequestIP(request);
    }
}
